home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Main.c
-
- Contains: A Sample application for dictionary access.
-
- Version: Technology: System 8
- Release: Daruma Developer Release 1
-
- Copyright: 1998 by Apple Computer, Inc., all rights reserved
-
- Contact: daruma@apple.com
-
- */
-
-
- #include "DictionaryAccess.h"
- #include "FunctionProto.h"
-
- #include <Menus.h>
- #include <Resources.h>
- #include <Dialogs.h>
- #include <Fonts.h>
- #include <AppleEvents.h>
- #include <Appearance.h>
- #include <TextServices.h>
-
- // ========================================================================================
- // Prototypes for static functions
- // ========================================================================================
- static void Initialize ( void );
- static void SetUpMenus ( void );
- static OSStatus InstallAppleEventHandlers( void );
-
-
- // ========================================================================================
- // main
- // ========================================================================================
- void main ( void )
- {
- Initialize();
- MainEventLoop();
- }
-
-
- // ========================================================================================
- // Initialize
- // ========================================================================================
- static void Initialize ( void )
- {
- //------------------------------------------------------------------------------
- // Initialize Toolbox
- //
- InitGraf( (Ptr)&qd.thePort);
- InitFonts();
- FlushEvents( everyEvent, 0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( nil);
- InitCursor();
- InitTSMAwareApplication();
- RegisterAppearanceClient();
-
- //------------------------------------------------------------------------------
- // Initialize application part
- //
- SetUpMenus();
- InstallAppleEventHandlers();
- }
-
-
- // ========================================================================================
- // SetUpMenus
- // ========================================================================================
- static void SetUpMenus ( void )
- {
- Handle menuBar;
- UInt16 i;
-
- menuBar = GetNewMBar( kMenuBarResID);
- SetMenuBar( menuBar);
-
- AppendResMenu( GetMenuHandle( kAppleMenuID), 'DRVR');
-
- //------------------------------------------------------------------------------
- // Pre-load all popup menus because the menu which loaded at creating popup menu
- // is disposed on DisposeDialog. This can be a problem on multi window application.
- //
- for ( i = kFirstPopupMenuID; i <= kLastPopupMenuID; i++ )
- {
- InsertMenu( GetMenu( i), hierMenu);
- }
-
- DrawMenuBar();
- }
-
-
- // ========================================================================================
- // InstallAppleEventHandlers
- // ========================================================================================
-
- static OSStatus InstallAppleEventHandlers( void )
- {
- OSStatus err;
-
- err = AEInstallEventHandler( kCoreEventClass, kAEQuitApplication,
- NewAEEventHandlerProc( AEQuitHandler), 0, false);
-
- return err;
- }
-
-
-
-